package niuke;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

public class Test3 {
	public static void main(String[] args) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		List<Test3.Record> records = new ArrayList<Test3.Record>();
		String s = null;
		while ((s = in.readLine()) != null) {
			if (s.equals("over")) {
				break;
			}
			s = s.substring(s.lastIndexOf("\\") + 1);
			String[] strs = s.split(" ");

			String fileName = strs[0].trim();// 文件名
			int number = Integer.parseInt(strs[1].trim());// 出现错误的行数
			Record record = new Record(fileName, number);
			searchRecord(records, record);
		}
		// 排序
		Collections.sort(records);
		if (8 >= records.size()) {
			for (int i = 0; i < records.size(); i++) {
				System.out.println(records.get(i).getName() + " "
						+ records.get(i).number + " " + records.get(i).count);
			}
		} else {
			for (int i = 0; i < 8; i++) {
				System.out.println(records.get(i).getName() + " "
						+ records.get(i).number + " " + records.get(i).count);
			}
		}
	}

	private static void searchRecord(List<Record> records, Record record) {
		for (int i = 0; i < records.size(); i++) {
			if (records.get(i).equals(record)) {
				record.count = records.get(i).count + 1;
				records.set(i, record);
				return;
			}
		}
		record.count = 1;
		records.add(record);
	}

	private static class Record implements Comparable<Record> {
		public Record(String name, int number, int count) {
			super();
			this.name = name;
			this.number = number;
			this.count = count;
		}

		private String name;
		private int number;
		private int count;

		public Record(String name, int number) {
			super();
			this.name = name;
			this.number = number;
		}

		@Override
		public int hashCode() {
			final int prime = 31;
			int result = 1;
			result = prime * result + ((name == null) ? 0 : name.hashCode());
			result = prime * result + number;
			return result;
		}

		@Override
		public boolean equals(Object obj) {
			if (this == obj)
				return true;
			if (obj == null)
				return false;
			if (getClass() != obj.getClass())
				return false;
			Record other = (Record) obj;
			if (name == null) {
				if (other.name != null)
					return false;
			} else if (!name.equals(other.name))
				return false;
			if (number != other.number)
				return false;
			return true;
		}

		@Override
		public int compareTo(Record o) {
			// TODO Auto-generated method stub
			return o.count - this.count;
		}

		public String getName() {
			if (this.name.length() > 16) {
				return name.substring(name.length() - 16);
			} else {
				return name;
			}
		}

		@Override
		public String toString() {
			return "Record [name=" + name + ", number=" + number + ", count="
					+ count + "]";
		}

	}
}
